package com.exception.solve;

import java.io.FileReader;

public class TestTryWithResource {
    public static void main(String[] args) {
        //重点是将声明写进try(声明)，就可以实现close()，其实是编译器将其转化为try(){}catch{}
        try(FileReader reader = new FileReader("D:/a.txt");) {
            char c1 = (char)reader.read();
            char c2 = (char)reader.read();
            char c3 = (char)reader.read();
            System.out.println(""+c1+c2+c3);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
